package com.yunhoo.zh.bean;

import com.yunhoo.base.model.Department;
import com.yunhoo.base.model.Organization;
import com.yunhoo.base.model.Person;
import com.yunhoo.sys.login.LoginInfo;
import com.yunhoo.zh.db.impl.UserAccountImpl;
import com.yunhoo.zh.model.UserAccount;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;

/**
 * 用户帐套.
 *
 */
@ManagedBean
@SessionScoped
public class UserAccountBean implements Serializable {

    private List<UserAccount> actli = null;
    private UserAccount act = null;

    public UserAccountBean() {
        act = new UserAccount();
    }
    
    public void initAccount(){
        Map<String,String> paramMap = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
        Long id_u = Long.parseLong((String)paramMap.get("id_u"));
        
        act.setId_u(id_u);
        
        UserAccountImpl.initAccount(act);
    }

    private void saveLoginInfoInSession() {
        Integer iyear = null;
        Organization org = null;
        Department dept = null;
        Person user = null;
        Date loginDate = null;
        
        ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext();
        Map sessionMap = extContext.getSessionMap();
        sessionMap.put("loginInfo", new LoginInfo(iyear, org, dept, user, loginDate));
    }
    
    

    public List<UserAccount> getActli() {
        return actli;
    }

    public void setActli(List<UserAccount> actli) {
        this.actli = actli;
    }

    public UserAccount getAct() {
        return act;
    }

    public void setAct(UserAccount act) {
        this.act = act;
    }
}
